﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Romeo.Data
{
    public class StaticScoreEvaluator : Evaluator
    {
        protected int[] _Scores = new int[Board.CellCount];

        public StaticScoreEvaluator (int a11, int a12, int a13, int a14,
                                              int a22, int a23, int a24,
                                                       int a33, int a34,
                                                                int a44)
        {
            _Scores[11] =               _Scores[18] =               _Scores[81] =               _Scores[88] =               a11;
            _Scores[12] = _Scores[21] = _Scores[17] = _Scores[71] = _Scores[82] = _Scores[28] = _Scores[87] = _Scores[78] = a12;
            _Scores[13] = _Scores[31] = _Scores[16] = _Scores[61] = _Scores[83] = _Scores[38] = _Scores[86] = _Scores[68] = a13;
            _Scores[14] = _Scores[41] = _Scores[15] = _Scores[51] = _Scores[84] = _Scores[48] = _Scores[85] = _Scores[58] = a14;

            _Scores[22] =               _Scores[27] =               _Scores[72] =               _Scores[77] =               a22;
            _Scores[23] = _Scores[32] = _Scores[26] = _Scores[62] = _Scores[73] = _Scores[37] = _Scores[76] = _Scores[67] = a23;
            _Scores[24] = _Scores[42] = _Scores[25] = _Scores[52] = _Scores[74] = _Scores[47] = _Scores[75] = _Scores[57] = a24;

            _Scores[33] =               _Scores[36] =               _Scores[63] =               _Scores[66] =               a33;
            _Scores[34] = _Scores[43] = _Scores[35] = _Scores[53] = _Scores[64] = _Scores[46] = _Scores[65] = _Scores[56] = a34;

            _Scores[44] =               _Scores[45] =               _Scores[54] =               _Scores[55] =               a44;
        }

        public StaticScoreEvaluator (int aScore)
            : this (aScore, aScore, aScore, aScore, aScore, aScore, aScore, aScore, aScore, aScore)
        {
        }

        public override int Evaluate (Board aBoard, int aMinScore)
        {
            int n = 0;
            for (int i = 11; i < 89; i++)
            {
                n += aBoard._Cells[i] * _Scores[i];
            }
            return n;
        }
    }
}
